dim points#(45)(45)(3)      ' The Array For The Points On The Grid Of Our "Wave"
dim wiggle_count            ' Counter Used To Control How Fast Flag Waves
wiggle_count = 0

dim xrot#                   ' X Rotation ( NEW )
dim yrot#                   ' Y Rotation ( NEW )
dim zrot#                   ' Z Rotation ( NEW )
dim hold#                   ' Temporarily Holds A Floating Point Value

dim texture                 ' Storage For One Texture ( NEW )

dim float_x#, float_y#, float_xb#, float_yb#


dim x, y

    ' Load Bitmaps
    texture = LoadTexture ("Data/Tim.bmp")
    glBindTexture (GL_TEXTURE_2D, texture)
    glBindTexture(GL_TEXTURE_2D, texture)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)

    glEnable(GL_TEXTURE_2D)                             ' Enable Texture Mapping ( NEW )
    glShadeModel(GL_SMOOTH)                             ' Enable Smooth Shading
    glClearColor(0.0, 0.0, 0.0, 0.5)                    ' Black Background
    glClearDepth(1.0)                                   ' Depth Buffer Setup
    glEnable(GL_DEPTH_TEST)                             ' Enables Depth Testing
    glDepthFunc(GL_LEQUAL)                              ' The Type Of Depth Testing To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)   ' Really Nice Perspective Calculations
    glPolygonMode( GL_BACK, GL_FILL )                   ' Back Face Is Solid
    glPolygonMode( GL_FRONT, GL_LINE )                  ' Front Face Is Made Of Lines

    glEnable(GL_TEXTURE_2D)                             ' Enable Texture Mapping ( NEW )
    glShadeModel(GL_SMOOTH)                             ' Enable Smooth Shading
    glClearColor(0.0, 0.0, 0.0, 0.5)                    ' Black Background
    glClearDepth(1.0)                                   ' Depth Buffer Setup
    glEnable(GL_DEPTH_TEST)                             ' Enables Depth Testing
    glDepthFunc(GL_LEQUAL)                              ' The Type Of Depth Testing To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)   ' Really Nice Perspective Calculations
    glPolygonMode( GL_BACK, GL_FILL )                   ' Back Face Is Solid
    glPolygonMode( GL_FRONT, GL_LINE )                  ' Front Face Is Made Of Lines

    for x = 0 to 44
        for y = 0 to 44
            points#(x)(y)(0)=(x/5.0)-4.5
            points#(x)(y)(1)=(y/5.0)-4.5
            points#(x)(y)(2)=sin((((x/5.0)*40.0)/360.0)*3.141592654*2.0)
        next
    next

    
    ' Main loop
    while true

        ' Here's Where We Do All The Drawing

        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)     ' Clear The Screen And The Depth Buffer
        glLoadIdentity()                                        ' Reset The View

        glTranslatef(0.0,0.0,-12.0)
      
        glRotatef(xrot#,1.0,0.0,0.0)
        glRotatef(yrot#,0.0,1.0,0.0)  
        glRotatef(zrot#,0.0,0.0,1.0)

        glBindTexture(GL_TEXTURE_2D, texture)

        glBegin(GL_QUADS)
        for x = 0 to 43
            for y = 0 to 43
                float_x# = (x)/44.0
                float_y# = (y)/44.0
                float_xb# = (x+1)/44.0
                float_yb# = (y+1)/44.0
                    
                glTexCoord2f( float_x#, float_y#)
                glVertex3f( points#(x)(y)(0), points#(x)(y)(1), points#(x)(y)(2) )

                glTexCoord2f( float_x#, float_yb# )
                glVertex3f( points#(x)(y+1)(0), points#(x)(y+1)(1), points#(x)(y+1)(2) )

                glTexCoord2f( float_xb#, float_yb# )
                glVertex3f( points#(x+1)(y+1)(0), points#(x+1)(y+1)(1), points#(x+1)(y+1)(2) )

                glTexCoord2f( float_xb#, float_y# )
                glVertex3f( points#(x+1)(y)(0), points#(x+1)(y)(1), points#(x+1)(y)(2) )
            next
        next
        glEnd()
        SwapBuffers ()
                      
        if wiggle_count = 2 then
            for y = 0 to 44
                hold#=points#(0)(y)(2)
                for x = 0 to 43
                    points#(x)(y)(2) = points#(x+1)(y)(2)
                next
                points#(44)(y)(2) = hold#
            next
            wiggle_count = 0
        endif
        wiggle_count = wiggle_count + 1              

        xrot# = xrot# + 0.3
        yrot# = yrot# + 0.2
        zrot# = zrot# + 0.4
    wend